home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / mail / YAMscripts.lha / CountryCode.rexx < prev    next >
OS/2 REXX Batch file  |  1997-06-25  |  2KB  |  104 lines

  1. /* Shows country codes of addresses in the current message with 
  2. ** CountryCodes v1.0 by Paul Kolenbrander
  3. ** CountryCodes can be found in Aminet comm/www/CountryCodes.lha
  4. ** 
  5. ** YAM script written by Kai Nikulainen.  If you have comments about the script,
  6. ** send mail to knikulai@utu.fi
  7. */
  8. options results
  9.  
  10. /* CHANGE the correct path to the following line */
  11. coco_prg='Packed:Datacomm/CountryCodes/CountryCodes' 
  12.  
  13.  gtxt='Select address:*n'    /* Change these to modify the requester */
  14.  gscr='_Scroll'            /* _ means keyboard shortcut */
  15.  gbut='_Exit'
  16.  
  17.  hdrs=4        /* Search e-mail addresses from these headers */
  18. hdr.1='To:'
  19. hdr.2='From:'
  20. hdr.3='Cc:'
  21. hdr.4='Bcc:'
  22.  
  23. adrs=0
  24.  
  25. address 'YAM'
  26. 'GetMailInfo File'
  27. call GetAddrs(result)
  28.  
  29. cur=1
  30.  
  31. if pos(' COCO',show(p))=0 then address command 'run >nil:' coco_prg
  32. l=show(p)
  33. p=pos('COCO',l)
  34. coco=substr(l,p,5)
  35.  
  36. do while 1
  37.     newcur=CreateRequester(cur)
  38.     address 'YAM' 'request "'txt'" "'but'"'
  39.     if result=0 then exit
  40.     if result=ScrollButton then
  41.         cur=newcur
  42.     else do
  43.         index=cur+result-1
  44.         p=lastpos('.',adr.index)
  45.         suf=substr(adr.index,p)
  46.         address value coco 
  47.          'WINDOW FRONT'
  48.         'LOCATE' suf
  49.         end
  50.     end
  51. exit
  52.  
  53. CreateRequester:
  54. parse arg c
  55.     txt=gtxt
  56.     but=''
  57.     b=1
  58.     old_c=c
  59.     do until c>adrs | b=8 | 210<(length(txt)+length(gscr)+length(gbut)+length(but)) 
  60.         txt=txt || b')' adr.c || '*n'
  61.         but=but || '_' || b || '|'
  62.         c=c+1
  63.         b=b+1
  64.         end
  65.     if old_c>1 | c<adrs then but=but || gscr'|'
  66.     but=but || gbut        
  67.     ScrollButton=b
  68.     if c>adrs then c=1
  69. return c
  70.  
  71. GetAddrs: procedure expose hdrs hdr. adrs adr.
  72. parse arg fn
  73.     call open(1,fn,'r')
  74.     do until eof(1) | r=''
  75.         r=translate(readln(1),' ','<>,'||'09'x)
  76.         w1=word(r,1)
  77.         if right(w1,1)=':' then h=upper(w1)
  78.         do i=1 to hdrs
  79.             if upper(hdr.i)=h then call Extract(r)
  80.             end
  81.         end /* until */
  82.     call close(1)
  83. return
  84.  
  85. Extract: procedure expose adrs adr.
  86. parse arg line
  87.     do i=1 to words(line)
  88.         w=word(line,i)
  89.         if pos('@',w)>0 then call AddIt(w)
  90.         end
  91. return
  92.  
  93. AddIt: procedure expose adrs adr.
  94. parse arg a
  95.     found_it=0
  96.     do i=1 to adrs
  97.         if upper(a)=upper(adr.i) then found_it=1
  98.         end
  99.     if ~found_it then do
  100.         adrs=adrs+1
  101.         adr.adrs=a
  102.         end
  103. return
  104.